package com.sunagy.demand.front.controller;

import com.sunagy.demand.front.VO.ResultVO;
import com.sunagy.demand.front.dto.ProductDto;
import com.sunagy.demand.front.service.ProductService;
import com.sunagy.demand.front.utils.ResultVOUtil;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * desc：#TODO fill me ！
 * author：三餘無夢生
 * date：2018/4/27
 * time：下午12:52
 */
@Slf4j
@RestController
@RequestMapping("/product")
@Api(value = "管理端产品模块", description = "管理端产品模块")
public class ProductController {

    @Autowired
    protected ProductService productService;


    @ApiOperation(value = "查询产品列表", notes = "树形返回所有产品不分页")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "java.lang.String", name = "token", value = "token", required = false, paramType = "header")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "接口异常")
    })
    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResultVO<List<ProductDto>> getTree() {
        List<ProductDto> productDtoList = productService.getTree();
        return ResultVOUtil.success(productDtoList);
    }

    @ApiOperation(value = "查询产品列表", notes = "列表返回所有产品不分页")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "java.lang.String", name = "token", value = "token", required = false, paramType = "header")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "接口异常")
    })
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResultVO<List<ProductDto>> getList() {
        List<ProductDto> productDtoList = productService.getList();
        return ResultVOUtil.success(productDtoList);
    }

}
